/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.common.i;

import android.content.Context;
import android.os.Environment;
import android.text.TextUtils;
import android.text.format.Time;
import android.util.Log;
import android.util.SparseArray;
import com.qihoo.gamecenter.sdk.common.d;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;

public class j {
    private static boolean b = false;
    private static boolean c = false;
    private static boolean d = false;
    private static boolean e = false;
    private static boolean f = false;
    private static boolean g = false;
    public static final boolean a = c;
    private static SparseArray h = null;
    private static FileOutputStream i = null;

    public static void a(String paramString1, String paramString2, Object[] paramArrayOfObject) {
        if (c)
            Log.d(paramString1 + paramString2, a(paramArrayOfObject));
        if (!(g))
            return;
        a(3, paramString1, paramString2, new Object[] { a(paramArrayOfObject) });
    }

    public static void b(String paramString1, String paramString2, Object[] paramArrayOfObject) {
        if (d)
            Log.i(paramString1 + paramString2, a(paramArrayOfObject));
        if (!(g))
            return;
        a(4, paramString1, paramString2, new Object[] { a(paramArrayOfObject) });
    }

    public static void c(String paramString1, String paramString2, Object[] paramArrayOfObject) {
        if (e)
            Log.w(paramString1 + paramString2, a(paramArrayOfObject));
        if (!(g))
            return;
        a(5, paramString1, paramString2, new Object[] { a(paramArrayOfObject) });
    }

    public static void d(String paramString1, String paramString2, Object[] paramArrayOfObject) {
        if (f)
            Log.e(paramString1 + paramString2, a(paramArrayOfObject));
        if (!(g))
            return;
        a(6, paramString1, paramString2, new Object[] { a(paramArrayOfObject) });
    }

    public static synchronized void a(int paramInt, String paramString1, String paramString2,
            Object[] paramArrayOfObject) {
        if (!(g))
            return;
        a(paramInt, paramString1 + paramString2, a(paramArrayOfObject));
    }

    private static synchronized void a(int paramInt, String paramString1, String paramString2) {
        if (i == null)
            a();
        if (i == null)
            return;
        try {
            Time localTime = new Time();
            localTime.setToNow();
            String str = localTime.format2445() + " " + ((String) h.get(paramInt)) + "/" + paramString1 + " "
                    + paramString2 + "\r\n";
            i.write(str.getBytes("UTF-8"));
            i.flush();
        } catch (Exception localException) {
            localException.printStackTrace();
            try {
                i.close();
            } catch (IOException localIOException) {
                localIOException.printStackTrace();
            }
            i = null;
        }
    }

    private static void a() {
        if (!(Environment.getExternalStorageState().equals("mounted")))
            return;
        File localFile = new File(Environment.getExternalStorageDirectory(), "trace.txt");
        try {
            i = new FileOutputStream(localFile, true);
        } catch (FileNotFoundException localFileNotFoundException) {
            localFileNotFoundException.printStackTrace();
        }
    }

    public static void a(Context paramContext, String paramString) {}

    private static String a(Object[] paramArrayOfObject) {
        StringBuilder localStringBuilder = new StringBuilder();
        for (Object localObject : paramArrayOfObject)
            if (null == localObject)
                localStringBuilder.append("null");
            else
                localStringBuilder.append(localObject.toString());
        return localStringBuilder.toString();
    }

    public static void a(Context paramContext) {
        String str = d.d(paramContext);
        if ((!(TextUtils.isEmpty(str))) && (str.length() == 16) && (str.startsWith("qch_" + c()))
                && (d.a() + b().equals(k.a(str.substring(10))))) {
            b = true;
            c = true;
            d = true;
            e = true;
            f = true;
            g = true;
        }
        str = "";
    }

    private static String b() {
        return "3ef91f07e4cdd".toLowerCase();
    }

    private static String c() {
        String str = "";
        Date localDate = new Date();
        int j = localDate.getMonth() + 1;
        int k = localDate.getDate();
        int l = localDate.getHours();
        if (j < 10)
            str = str + "0" + j;
        else
            str = str + j;
        if (k < 10)
            str = str + "0" + k;
        else
            str = str + k;
        if (l < 10)
            str = str + "0" + l;
        else
            str = str + l;
        return str;
    }

    static {
        h = new SparseArray();
        h.put(2, "V");
        h.put(3, "D");
        h.put(4, "I");
        h.put(5, "W");
        h.put(6, "E");
    }
}